package com.bichengcao.googlecodejam.gcj2008beta;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;

public class TriangleTrilemma {

	static int N;

	public static void main(String[] args) throws IOException {
		Input[] inputs = parseInput("src/com/bichengcao/googlecodejam/gcj2008beta/A-small-practice.in");
		Output[] outputs = process(inputs);
		writeOutput("src/com/bichengcao/googlecodejam/gcj2008beta/TriangleTrilemma.out", outputs);
	}

	static class Input {

		int x1, y1, x2, y2, x3, y3;
	}

	static class Output {

		boolean isTriangle = true;
		String angle;
		String sideLength;
	}
	
	private static Input[] parseInput(String filename) throws IOException {
		BufferedReader in = new BufferedReader(new FileReader(filename));
		N = Integer.parseInt(in.readLine());
		Input[] array = new Input[N];

		for (int i = 0; i < N; i++) {
			Input input = array[i] = new Input();
			String line = in.readLine();
			String[] splits = line.split(" ");
			input.x1 = Integer.parseInt(splits[0]);
			input.y1 = Integer.parseInt(splits[1]);
			input.x2 = Integer.parseInt(splits[2]);
			input.y2 = Integer.parseInt(splits[3]);
			input.x3 = Integer.parseInt(splits[4]);
			input.y3 = Integer.parseInt(splits[5]);
		}

		in.close();
		return array;
	}

	private static Output[] process(Input[] inputs) {
		Output[] outputs = new Output[N];
		for (int i = 0; i < N; i++) {
			outputs[i] = process(inputs[i]);
		}
		return outputs;
	}

	private static Output process(Input input) {
		Output output = new Output();

		int[] lengths = new int[3];
		lengths[0] = (input.x1 - input.x2) * (input.x1 - input.x2) + (input.y1 - input.y2) * (input.y1 - input.y2);
		lengths[1] = (input.x1 - input.x3) * (input.x1 - input.x3) + (input.y1 - input.y3) * (input.y1 - input.y3);
		lengths[2] = (input.x2 - input.x3) * (input.x2 - input.x3) + (input.y2 - input.y3) * (input.y2 - input.y3);
		Arrays.sort(lengths);
		
		if (lengths[0] == 0 ||
				(input.x1 == input.x2 && input.x1 == input.x3) ||
				(input.y1 == input.y2 && input.y1 == input.y3) ||
				(input.y1 - input.y2) * (input.x1 - input.x3) == (input.y1 - input.y3) * (input.x1 - input.x2)) {
			output.isTriangle = false;
			return output;
		}
		
		if (lengths[0] + lengths[1] > lengths[2]) {
			output.angle = "acute";
		} else if (lengths[0] + lengths[1] == lengths[2]) {
			output.angle = "right";
		} else if (lengths[0] + lengths[1] < lengths[2]) {
			output.angle = "obtuse";
		}
		
		if (lengths[0] == lengths[1] || lengths[1] == lengths[2]) {
			output.sideLength = "isosceles";
		} else {
			output.sideLength = "scalene";
		}

		return output;
	}

	private static void writeOutput(String filename, Output[] outputs) throws IOException {
		PrintWriter out = new PrintWriter(new FileWriter(filename));
		for (int i = 0; i < N; i++) {
			out.print("Case #" + (i + 1) + ": ");
			if (outputs[i].isTriangle) {
				out.println(outputs[i].sideLength + " " + outputs[i].angle + " triangle");
			} else {
				out.println("not a triangle");
			}
		}
		out.close();
	}
}
